Change in openvpn[master]: management: ensure consistent BYTECOUNT timing on server
A message that is not in the archive (sent off-list or not yet received): gerrit.1760942237000.Ifb1c49fce75e671f699f5db5f6da7246f6e0b519@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1285?usp=email
to review the following change.
Change subject: management: ensure consistent BYTECOUNT timing on server
......................................................................
management: ensure consistent BYTECOUNT timing on server
The BYTECOUNT notification is expected to be emitted every N seconds when a management client issues the 'bytecount N' command. However, the server currently relies on timeouts from unrelated periodic operations, resulting in irregular notification timing.
This issue is especially noticeable with low bytecount intervals and DCO enabled, as openvpn handles less traffic in userspace, causing the main loop to run less frequently.
To address this, refactor the timeout logic and pass the timeval reference to management_check_bytecount_server so that the timeout is correctly set and notifications adhere to the specified interval.
---
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/multi.c
M src/openvpn/multi.h
4 files changed, 17 insertions(+), 13 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1285/1
src/openvpn/manage.c +2 -4
@@ -4184,16 +4184,14 @@ }void -management_check_bytecount_server (struct multi_context *multi) +management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval) {if (!(management->persist.callback.flags &MCF_SERVER )) {return ; } -struct timeval null; -CLEAR (null); -if (event_timeout_trigger (&management->connection.bytecount_update_interval, &null,ETT_DEFAULT )) +if (event_timeout_trigger (&management->connection.bytecount_update_interval, timeval,ETT_DEFAULT )) {/* fetch counters from dco */ if (dco_enabled (&multi->top.options))
src/openvpn/manage.h +1 -1
@@ -493,7 +493,7 @@void management_check_bytecount_client (struct context *c,struct management *man,struct timeval *timeval); -void management_check_bytecount_server (struct multi_context *multi); +void management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +13 -7
@@ -3809,13 +3809,6 @@ {check_stale_routes (m); } - -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_check_bytecount_server (m); - } -#endif /* ENABLE_MANAGEMENT */ } static void
@@ -4166,6 +4159,19 @@ASSERT (mi->context.c2.tls_multi->peer_id < m->max_clients); } +static void +multi_get_timeout (struct multi_context *multi,struct timeval *timeval) +{ +multi_get_timeout_instance (multi, timeval); + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (multi, timeval); + } +#endif +} +/**************************************************************************/ /** * Main event loop for OpenVPN in point-to-multipoint server mode.
src/openvpn/multi.h +1 -1
@@ -590,7 +590,7 @@* to current time. */ static inline void -multi_get_timeout (struct multi_context *m,struct timeval *dest) +multi_get_timeout_instance (struct multi_context *m,struct timeval *dest) {struct timeval tv, current;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1285?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifb1c49fce75e671f699f5db5f6da7246f6e0b519
Gerrit-Change-Number: 1285
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1285?usp=email
to look at the new patch set (#2).
Change subject: management: ensure consistent BYTECOUNT timing on server
......................................................................
management: ensure consistent BYTECOUNT timing on server
The BYTECOUNT notification is expected to be emitted every N seconds when a management client issues the 'bytecount N' command. However, the server currently relies on timeouts from unrelated periodic operations, resulting in irregular notification timing.
This issue is especially noticeable with low bytecount intervals and DCO enabled, as openvpn handles less traffic in userspace, causing the main loop to run less frequently.
To address this, refactor the timeout logic and pass the timeval reference to management_check_bytecount_server so that the timeout is correctly set and notifications adhere to the specified interval.
---
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/multi.c
M src/openvpn/multi.h
4 files changed, 33 insertions(+), 18 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1285/2
src/openvpn/manage.c +2 -4
@@ -4184,16 +4184,14 @@ }void -management_check_bytecount_server (struct multi_context *multi) +management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval) {if (!(management->persist.callback.flags &MCF_SERVER )) {return ; } -struct timeval null; -CLEAR (null); -if (event_timeout_trigger (&management->connection.bytecount_update_interval, &null,ETT_DEFAULT )) +if (event_timeout_trigger (&management->connection.bytecount_update_interval, timeval,ETT_DEFAULT )) {/* fetch counters from dco */ if (dco_enabled (&multi->top.options))
src/openvpn/manage.h +1 -1
@@ -493,7 +493,7 @@void management_check_bytecount_client (struct context *c,struct management *man,struct timeval *timeval); -void management_check_bytecount_server (struct multi_context *multi); +void management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +23 -7
@@ -3809,13 +3809,6 @@ {check_stale_routes (m); } - -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_check_bytecount_server (m); - } -#endif /* ENABLE_MANAGEMENT */ } static void
@@ -4166,6 +4159,29 @@ASSERT (mi->context.c2.tls_multi->peer_id < m->max_clients); } +/** +* @brief Determines the earliest wakeup interval based on periodic operations. +* +* Updates the \c timeval to reflect the next scheduled wakeup time. +* Also sets \c multi->earliest_wakeup to the instance with the earliest wakeup. +* +* @param multi Pointer to the multi context +* @param timeval Pointer to the timeval structure to be updated with the +* next wakeup time +*/ +static void +multi_get_timeout (struct multi_context *multi,struct timeval *timeval) +{ +multi_get_timeout_instance (multi, timeval); + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (multi, timeval); + } +#endif /* ENABLE_MANAGEMENT */ +} +/**************************************************************************/ /** * Main event loop for OpenVPN in point-to-multipoint server mode.
src/openvpn/multi.h +7 -6
@@ -582,15 +582,16 @@ }/* -* Compute earliest timeout expiry from the set of -* all instances. Output: +* Updates \c dest with the earliest timeout as a delta relative to the current +* time and sets \c m->earliest_wakeup to the \c multi_instance with the +* soonest scheduled wakeup. * -* m->earliest_wakeup : instance needing the earliest service. -* dest : earliest timeout as a delta in relation -* to current time. +* @param m Pointer to the multi context +* @param dest Pointer to a timeval struct that will hold the earliest timeout +* delta. */ static inline void -multi_get_timeout (struct multi_context *m,struct timeval *dest) +multi_get_timeout_instance (struct multi_context *m,struct timeval *dest) {struct timeval tv, current;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1285?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifb1c49fce75e671f699f5db5f6da7246f6e0b519
Gerrit-Change-Number: 1285
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos, ralf_lici.
stipa has posted comments on this change by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1285?usp=email )
Change subject: management: ensure consistent BYTECOUNT timing on server
......................................................................
Patch Set 2: Code-Review+2
(1 comment)
Patchset:
PS2:
LGTM. The previous implementation triggered BYTECOUNT callback at most every 10 seconds, even with a smaller interval - this is due to instance reaper timeout being set to 10 secs, and we haven't checked BYTECOUNT timeout against any timeval instance.
This checks BYTECOUNT timeout expiration against multi->top.c2.timeval, the one used by multi_io_wait, which means that any interval will now work.
Tested on Windows server setup.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1285?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifb1c49fce75e671f699f5db5f6da7246f6e0b519
Gerrit-Change-Number: 1285
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Comment-Date: Tue, 21 Oct 2025 07:00:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
PATCH v2 1/1 management: ensure consistent BYTECOUNT timing on server
In reply to a message not in the archiveFrom: Ralf Lici <[email protected]...>
The BYTECOUNT notification is expected to be emitted every N seconds when a management client issues the 'bytecount N' command. However, the server currently relies on timeouts from unrelated periodic operations, resulting in irregular notification timing.
This issue is especially noticeable with low bytecount intervals and DCO enabled, as openvpn handles less traffic in userspace, causing the main loop to run less frequently.
To address this, refactor the timeout logic and pass the timeval reference to management_check_bytecount_server so that the timeout is correctly set and notifications adhere to the specified interval.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1285
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Lev Stipakov <[email protected]...>
src/openvpn/manage.c +2 -4
@@ -4184,16 +4184,14 @@ }void -management_check_bytecount_server (struct multi_context *multi) +management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval) {if (!(management->persist.callback.flags &MCF_SERVER )) {return ; } -struct timeval null; -CLEAR (null); -if (event_timeout_trigger (&management->connection.bytecount_update_interval, &null,ETT_DEFAULT )) +if (event_timeout_trigger (&management->connection.bytecount_update_interval, timeval,ETT_DEFAULT )) {/* fetch counters from dco */ if (dco_enabled (&multi->top.options))
src/openvpn/manage.h +1 -1
@@ -493,7 +493,7 @@void management_check_bytecount_client (struct context *c,struct management *man,struct timeval *timeval); -void management_check_bytecount_server (struct multi_context *multi); +void management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +23 -7
@@ -3809,13 +3809,6 @@ {check_stale_routes (m); } - -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_check_bytecount_server (m); - } -#endif /* ENABLE_MANAGEMENT */ } static void
@@ -4166,6 +4159,29 @@ASSERT (mi->context.c2.tls_multi->peer_id < m->max_clients); } +/** +* @brief Determines the earliest wakeup interval based on periodic operations. +* +* Updates the \c timeval to reflect the next scheduled wakeup time. +* Also sets \c multi->earliest_wakeup to the instance with the earliest wakeup. +* +* @param multi Pointer to the multi context +* @param timeval Pointer to the timeval structure to be updated with the +* next wakeup time +*/ +static void +multi_get_timeout (struct multi_context *multi,struct timeval *timeval) +{ +multi_get_timeout_instance (multi, timeval); + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (multi, timeval); + } +#endif /* ENABLE_MANAGEMENT */ +} +/**************************************************************************/ /** * Main event loop for OpenVPN in point-to-multipoint server mode.
src/openvpn/multi.h +7 -6
@@ -582,15 +582,16 @@ }/* -* Compute earliest timeout expiry from the set of -* all instances. Output: +* Updates \c dest with the earliest timeout as a delta relative to the current +* time and sets \c m->earliest_wakeup to the \c multi_instance with the +* soonest scheduled wakeup. * -* m->earliest_wakeup : instance needing the earliest service. -* dest : earliest timeout as a delta in relation -* to current time. +* @param m Pointer to the multi context +* @param dest Pointer to a timeval struct that will hold the earliest timeout +* delta. */ static inline void -multi_get_timeout (struct multi_context *m,struct timeval *dest) +multi_get_timeout_instance (struct multi_context *m,struct timeval *dest) {struct timeval tv, current;
[Openvpn-devel] [PATCH applied] Re: management: ensure consistent BYTECOUNT timing on server
Took a bit between +2 and merge, but here we are :-)
Tested on FreeBSD+DCO with "bytecount 2", which used to do "10 seconds and no less". New code does 2s if 2s is ordered... whether or not that is *useful* depends on the management client, I'd say :-) - but having consistent behaviour is a good thing.
Looking at the code, I did wonder why multi_get_timeout_instance() lives in multi.h, when it is only used from multi.c - this is actually a multisocket artefact. 2.6 calls this from mudp.c and mtcp.c, so it made sense. master/2.7 only calls this from multi.c, so we could move it in there eventually.
Your patch has been applied to the master branch.
commit a5ee6a1d642ae365eae78fd04d51976c365b2b59
Author: Ralf Lici Date: Tue Oct 21 09:08:20 2025 +0200
management: ensure consistent BYTECOUNT timing on server
Signed-off-by: Ralf Lici <[email protected]...>
Acked-by: Lev Stipakov <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33812.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH v2 1/1 management: ensure consistent BYTECOUNT timing on server
In reply to a message not in the archiveFrom: Ralf Lici <[email protected]...>
The BYTECOUNT notification is expected to be emitted every N seconds when a management client issues the 'bytecount N' command. However, the server currently relies on timeouts from unrelated periodic operations, resulting in irregular notification timing.
This issue is especially noticeable with low bytecount intervals and DCO enabled, as openvpn handles less traffic in userspace, causing the main loop to run less frequently.
To address this, refactor the timeout logic and pass the timeval reference to management_check_bytecount_server so that the timeout is correctly set and notifications adhere to the specified interval.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1285
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1285
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Lev Stipakov <[email protected]...>
src/openvpn/manage.c +2 -4
@@ -4184,16 +4184,14 @@ }void -management_check_bytecount_server (struct multi_context *multi) +management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval) {if (!(management->persist.callback.flags &MCF_SERVER )) {return ; } -struct timeval null; -CLEAR (null); -if (event_timeout_trigger (&management->connection.bytecount_update_interval, &null,ETT_DEFAULT )) +if (event_timeout_trigger (&management->connection.bytecount_update_interval, timeval,ETT_DEFAULT )) {/* fetch counters from dco */ if (dco_enabled (&multi->top.options))
src/openvpn/manage.h +1 -1
@@ -493,7 +493,7 @@void management_check_bytecount_client (struct context *c,struct management *man,struct timeval *timeval); -void management_check_bytecount_server (struct multi_context *multi); +void management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +23 -7
@@ -3809,13 +3809,6 @@ {check_stale_routes (m); } - -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_check_bytecount_server (m); - } -#endif /* ENABLE_MANAGEMENT */ } static void
@@ -4166,6 +4159,29 @@ASSERT (mi->context.c2.tls_multi->peer_id < m->max_clients); } +/** +* @brief Determines the earliest wakeup interval based on periodic operations. +* +* Updates the \c timeval to reflect the next scheduled wakeup time. +* Also sets \c multi->earliest_wakeup to the instance with the earliest wakeup. +* +* @param multi Pointer to the multi context +* @param timeval Pointer to the timeval structure to be updated with the +* next wakeup time +*/ +static void +multi_get_timeout (struct multi_context *multi,struct timeval *timeval) +{ +multi_get_timeout_instance (multi, timeval); + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (multi, timeval); + } +#endif /* ENABLE_MANAGEMENT */ +} +/**************************************************************************/ /** * Main event loop for OpenVPN in point-to-multipoint server mode.
src/openvpn/multi.h +7 -6
@@ -582,15 +582,16 @@ }/* -* Compute earliest timeout expiry from the set of -* all instances. Output: +* Updates \c dest with the earliest timeout as a delta relative to the current +* time and sets \c m->earliest_wakeup to the \c multi_instance with the +* soonest scheduled wakeup. * -* m->earliest_wakeup : instance needing the earliest service. -* dest : earliest timeout as a delta in relation -* to current time. +* @param m Pointer to the multi context +* @param dest Pointer to a timeval struct that will hold the earliest timeout +* delta. */ static inline void -multi_get_timeout (struct multi_context *m,struct timeval *dest) +multi_get_timeout_instance (struct multi_context *m,struct timeval *dest) {struct timeval tv, current;
cron2 has uploaded a new patch set (#3) to the change originally created by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1285?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by stipa
Change subject: management: ensure consistent BYTECOUNT timing on server
......................................................................
management: ensure consistent BYTECOUNT timing on server
The BYTECOUNT notification is expected to be emitted every N seconds when a management client issues the 'bytecount N' command. However, the server currently relies on timeouts from unrelated periodic operations, resulting in irregular notification timing.
This issue is especially noticeable with low bytecount intervals and DCO enabled, as openvpn handles less traffic in userspace, causing the main loop to run less frequently.
To address this, refactor the timeout logic and pass the timeval reference to management_check_bytecount_server so that the timeout is correctly set and notifications adhere to the specified interval.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33812.html
---
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/multi.c
M src/openvpn/multi.h
4 files changed, 33 insertions(+), 18 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1285/3
src/openvpn/manage.c +2 -4
@@ -4184,16 +4184,14 @@ }void -management_check_bytecount_server (struct multi_context *multi) +management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval) {if (!(management->persist.callback.flags &MCF_SERVER )) {return ; } -struct timeval null; -CLEAR (null); -if (event_timeout_trigger (&management->connection.bytecount_update_interval, &null,ETT_DEFAULT )) +if (event_timeout_trigger (&management->connection.bytecount_update_interval, timeval,ETT_DEFAULT )) {/* fetch counters from dco */ if (dco_enabled (&multi->top.options))
src/openvpn/manage.h +1 -1
@@ -493,7 +493,7 @@void management_check_bytecount_client (struct context *c,struct management *man,struct timeval *timeval); -void management_check_bytecount_server (struct multi_context *multi); +void management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +23 -7
@@ -3797,13 +3797,6 @@ {check_stale_routes (m); } - -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_check_bytecount_server (m); - } -#endif /* ENABLE_MANAGEMENT */ } static void
@@ -4154,6 +4147,29 @@ASSERT (mi->context.c2.tls_multi->peer_id < m->max_clients); } +/** +* @brief Determines the earliest wakeup interval based on periodic operations. +* +* Updates the \c timeval to reflect the next scheduled wakeup time. +* Also sets \c multi->earliest_wakeup to the instance with the earliest wakeup. +* +* @param multi Pointer to the multi context +* @param timeval Pointer to the timeval structure to be updated with the +* next wakeup time +*/ +static void +multi_get_timeout (struct multi_context *multi,struct timeval *timeval) +{ +multi_get_timeout_instance (multi, timeval); + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (multi, timeval); + } +#endif /* ENABLE_MANAGEMENT */ +} +/**************************************************************************/ /** * Main event loop for OpenVPN in point-to-multipoint server mode.
src/openvpn/multi.h +7 -6
@@ -581,15 +581,16 @@ }/* -* Compute earliest timeout expiry from the set of -* all instances. Output: +* Updates \c dest with the earliest timeout as a delta relative to the current +* time and sets \c m->earliest_wakeup to the \c multi_instance with the +* soonest scheduled wakeup. * -* m->earliest_wakeup : instance needing the earliest service. -* dest : earliest timeout as a delta in relation -* to current time. +* @param m Pointer to the multi context +* @param dest Pointer to a timeval struct that will hold the earliest timeout +* delta. */ static inline void -multi_get_timeout (struct multi_context *m,struct timeval *dest) +multi_get_timeout_instance (struct multi_context *m,struct timeval *dest) {struct timeval tv, current;
Signature · 14 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1285?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ifb1c49fce75e671f699f5db5f6da7246f6e0b519 Gerrit-Change-Number: 1285 Gerrit-PatchSet: 3 Gerrit-Owner: ralf_lici <[email protected]...> Gerrit-Reviewer: flichtenheld <[email protected]...> Gerrit-Reviewer: plaisthos <[email protected]...> Gerrit-Reviewer: stipa <[email protected]...> Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1285?usp=email )
Change subject: management: ensure consistent BYTECOUNT timing on server
......................................................................
management: ensure consistent BYTECOUNT timing on server
The BYTECOUNT notification is expected to be emitted every N seconds when a management client issues the 'bytecount N' command. However, the server currently relies on timeouts from unrelated periodic operations, resulting in irregular notification timing.
This issue is especially noticeable with low bytecount intervals and DCO enabled, as openvpn handles less traffic in userspace, causing the main loop to run less frequently.
To address this, refactor the timeout logic and pass the timeval reference to management_check_bytecount_server so that the timeout is correctly set and notifications adhere to the specified interval.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33812.html
---
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/multi.c
M src/openvpn/multi.h
4 files changed, 33 insertions(+), 18 deletions(-)
src/openvpn/manage.c +2 -4
@@ -4184,16 +4184,14 @@ }void -management_check_bytecount_server (struct multi_context *multi) +management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval) {if (!(management->persist.callback.flags &MCF_SERVER )) {return ; } -struct timeval null; -CLEAR (null); -if (event_timeout_trigger (&management->connection.bytecount_update_interval, &null,ETT_DEFAULT )) +if (event_timeout_trigger (&management->connection.bytecount_update_interval, timeval,ETT_DEFAULT )) {/* fetch counters from dco */ if (dco_enabled (&multi->top.options))
src/openvpn/manage.h +1 -1
@@ -493,7 +493,7 @@void management_check_bytecount_client (struct context *c,struct management *man,struct timeval *timeval); -void management_check_bytecount_server (struct multi_context *multi); +void management_check_bytecount_server (struct multi_context *multi,struct timeval *timeval);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +23 -7
@@ -3797,13 +3797,6 @@ {check_stale_routes (m); } - -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_check_bytecount_server (m); - } -#endif /* ENABLE_MANAGEMENT */ } static void
@@ -4154,6 +4147,29 @@ASSERT (mi->context.c2.tls_multi->peer_id < m->max_clients); } +/** +* @brief Determines the earliest wakeup interval based on periodic operations. +* +* Updates the \c timeval to reflect the next scheduled wakeup time. +* Also sets \c multi->earliest_wakeup to the instance with the earliest wakeup. +* +* @param multi Pointer to the multi context +* @param timeval Pointer to the timeval structure to be updated with the +* next wakeup time +*/ +static void +multi_get_timeout (struct multi_context *multi,struct timeval *timeval) +{ +multi_get_timeout_instance (multi, timeval); + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (multi, timeval); + } +#endif /* ENABLE_MANAGEMENT */ +} +/**************************************************************************/ /** * Main event loop for OpenVPN in point-to-multipoint server mode.
src/openvpn/multi.h +7 -6
@@ -581,15 +581,16 @@ }/* -* Compute earliest timeout expiry from the set of -* all instances. Output: +* Updates \c dest with the earliest timeout as a delta relative to the current +* time and sets \c m->earliest_wakeup to the \c multi_instance with the +* soonest scheduled wakeup. * -* m->earliest_wakeup : instance needing the earliest service. -* dest : earliest timeout as a delta in relation -* to current time. +* @param m Pointer to the multi context +* @param dest Pointer to a timeval struct that will hold the earliest timeout +* delta. */ static inline void -multi_get_timeout (struct multi_context *m,struct timeval *dest) +multi_get_timeout_instance (struct multi_context *m,struct timeval *dest) {struct timeval tv, current;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1285?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifb1c49fce75e671f699f5db5f6da7246f6e0b519
Gerrit-Change-Number: 1285
Gerrit-PatchSet: 3
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>